<template>
  <div class="home">
    <h1>欢迎, {{ currentUser.username }}!</h1>
    <button @click="logout">退出登录</button>

    <h2>所有用户</h2>
    <UserList />
  </div>
</template>

<script>
import UserList from '@/components/UserList.vue'

export default {
  components: {
    UserList
  },
  computed: {
    currentUser() {
      return this.$store.getters['auth/currentUser']
    }
  },
  methods: {
    async logout() {
      await this.$store.dispatch('auth/logout')
      this.$router.push('/login')
    }
  },
  name: 'HomePage'  // 改为多单词名称
}
</script>